﻿using System;
using OOXMLGenerator.Enums;

namespace OOXMLGenerator.DataStructure
{
    /// <summary>
    /// Is a custom Section Content with PartContentType.Documents Type
    /// </summary>
    public class ECOHSectionContent : SectionContent
    {
        /// <summary>
        /// Empty constructors - initializes a new instance of the ECOHSectionContent Class.
        /// Properties settings:
        /// Header = Properties.Resources.Header_ECOHistory;
        /// Type = PartContentType.ECOHistory        
        /// Content = new instance of PartDataSet.PartECOHistoryDataTable
        /// </summary>
        public ECOHSectionContent()
        {
            base.Header = Properties.Resources.Header_ECOHistory;
            base.Type = PartContentType.ECOHistory;
            base.Content = new PartDataSet.PartECOHistoryDataTable();
        }

        /// <summary>
        /// Initializes a new instance of the ECOHSectionContent Class.
        /// Properties settings:
        /// Header = header
        /// Type = PartContentType.ECOHistory        
        /// Content = new instance of PartDataSet.PartECOHistoryDataTable
        /// </summary>
        /// <param name="header">Document Section Content header</param>
        public ECOHSectionContent(string header)
        {
            base.Header = header;
            base.Type = PartContentType.ECOHistory;
            base.Content = new PartDataSet.PartECOHistoryDataTable();
        }

        /// <summary>
        /// Adds a row to ECO History Section Content initialized with given parameters
        /// </summary>
        /// <param name="revision">ECO major revision</param>
        /// <param name="title">ECO title</param>
        /// <param name="status">ECO status</param>
        /// <param name="releaseDate">ECO relase date</param>
        public void AddECOHItem(string revision, string title, string status, DateTime? releaseDate)
        {
            PartDataSet.PartECOHistoryRow ecohRow = ((PartDataSet.PartECOHistoryDataTable)base.Content).NewPartECOHistoryRow();
            ecohRow.major_rev = revision;
            ecohRow.description = title;
            ecohRow.state = status;
            if (releaseDate != null)
                ecohRow.release_date = (DateTime)releaseDate;
            ((PartDataSet.PartECOHistoryDataTable)base.Content).AddPartECOHistoryRow(ecohRow);
        }
    }
}
